/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transervfx.Dato.Entidad;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.property.adapter.JavaBeanFloatProperty;
import javafx.beans.property.adapter.JavaBeanFloatPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanProperty;
import javafx.beans.property.adapter.JavaBeanStringProperty;
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

/**
 *
 * @author oscar
 */
@Entity

@NamedQueries ( { 
    @NamedQuery ( name = "TipoServicio.findAll", query = "SELECT ts FROM TipoServicio ts" )
    }
  )

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="SERVICIO_TIPO")
public abstract class TipoServicio implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    //el identity es para generarlo automaticamente y secuencialmente x la bd
    //el auto, tenes q poner el id vos, o lo genera el sistema pero no necesariamente en secuencia.
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    private String nombre;
    
    private String descripcion;
    
    private String prioridad;
    
    private Float precio;
       
  
    
    
    @Transient
    private JavaBeanStringProperty PROP_NOMBRE;
    @Transient
    private JavaBeanStringProperty PROP_DESCRIPCION;
    @Transient
    private JavaBeanStringProperty PROP_PRIORIDAD;
    @Transient
    private JavaBeanFloatProperty PROP_PRECIO;

    @Transient
    private ArrayList<JavaBeanProperty> GroupBindProperties = new ArrayList<>();

    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getPrioridad() {
        return prioridad;
    }

    public void setPrioridad(String prioridad) {
        this.prioridad = prioridad;
    }

    public Float getPrecio() {
        return precio;
    }

    public void setPrecio(Float precio) {
        this.precio = precio;
    }


    public JavaBeanStringProperty getPROP_NOMBRE() throws NoSuchMethodException {
        if (PROP_NOMBRE == null) {
            PROP_NOMBRE = JavaBeanStringPropertyBuilder.create().bean(this).name("nombre").build();
            getGroupBindProperties().add(PROP_NOMBRE);
        }
        return PROP_NOMBRE;
    }
  
    public JavaBeanStringProperty getPROP_DESCRIPCION() throws NoSuchMethodException {
        if (PROP_DESCRIPCION == null) {
            PROP_DESCRIPCION = JavaBeanStringPropertyBuilder.create().bean(this).name("descripcion").build();
            getGroupBindProperties().add(PROP_DESCRIPCION);
        }
        return PROP_DESCRIPCION;
    }

    public JavaBeanStringProperty getPROP_PRIORIDAD() throws NoSuchMethodException {
        if (PROP_PRIORIDAD == null) {
            PROP_PRIORIDAD = JavaBeanStringPropertyBuilder.create().bean(this).name("prioridad").build();
            getGroupBindProperties().add(PROP_PRIORIDAD);
        }
        return PROP_PRIORIDAD;
    }

    public JavaBeanFloatProperty getPROP_PRECIO() throws NoSuchMethodException {
        if (PROP_PRECIO == null) {
            PROP_PRECIO = JavaBeanFloatPropertyBuilder.create().bean(this).name("precio").build();
            getGroupBindProperties().add(PROP_PRECIO);
        }
        return PROP_PRECIO;
    }

    public ArrayList<JavaBeanProperty> getGroupBindProperties() {
        return GroupBindProperties;
    }


    public void unbindingALL() {
        for (JavaBeanProperty beanBinding : GroupBindProperties) {
            beanBinding.unbind();
        }
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoServicio)) {
            return false;
        }
        TipoServicio other = (TipoServicio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nombre;
    }
    
}
